<template>
	<view class="news-detail">
		<tetx class="title">{{detail.title}}</tetx>
		<view class="info">
				<text>发布时间:{{detail.add_time | formaData}}</text>
				<text>浏览:{{detail.click}}</text>
		</view>
		<view class="content">
			<rich-text :nodes="detail.content"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				detail:{}
			}
		},
		/* 过滤器 */
		filters:{
			formaData(date){
				const ndata = new Date(date)
				const year = ndata.getFullYear()
				const month = ndata.getMonth().toString().padStart(2,0)
				const day = ndata.getDay().toString().padStart(2,0)
				return year+'-'+month+'-'+day
			}
		},
		methods: {
			async getNewsDatile(){
			const res= await this.$myRequest({
					url:'/api/getnew/'+this.id
				})
				console.log(res)
				this.detail = res.data.message[0]
			}
			
		},
		onLoad(options){
			this.id = options.id
			this.getNewsDatile()
		}
	}
</script>

<style lang="scss">
	.news-detail{
		font-size: 30rpx;
		padding: 0 20rpx;
		.title{
			text-align: center;
			width: 750rpx;
			display: block;
			margin: 20rpx 0;
			font-size: 35rpx ;
		}
		.info{
			display: flex;
			justify-content: space-between;
			margin-bottom: 30rpx;
			font-size: 25rpx;
			
		}
	}
</style>
